import App from './App';
import router from './router';
import store from './store';
import './assets/font/font.css';
import { Lazyload } from 'vant';
import 'virtual:svg-icons-register';
// import useTable from './vxe';
// const app = createApp(App);
import 'element-plus/dist/index.css';
import 'vant/lib/index.css';
import { renderWithQiankun, qiankunWindow } from 'vite-plugin-qiankun/dist/helper';
import { vLoading } from 'element-plus/es/components/loading/src/directive';
// import { setToastDefaultOptions } from 'vant';
// app.provide('$imgPath', 'https://h5.mythinkcar.cn/vueh5/static/img/');

// app.use(router);
// app.use(store);
// app.directive('loading', vLoading);

// // 注册时可以配置额外的选项
// app.use(Lazyload, {
//   lazyComponent: true
// });

// // setToastDefaultOptions({ duration: 0,message: 'Loading...',forbidClick: true, loadingType: 'spinner',type: 'loading'});

// app.mount('#app');


// let app: any;
const app = createApp(App);
const render = (container:any) => {
  app.provide('$imgPath', 'https://h5.mythinkcar.cn/vueh5/static/img/');
  app.use(router);
  app.use(store);
  app.directive('loading', vLoading);
  app.use(Lazyload, {
    lazyComponent: true
  });
  app.mount(container)
}
if (!qiankunWindow.__POWERED_BY_QIANKUN__) {
  render("#app")
} else {
  renderWithQiankun({
    // 子应用挂载
    mount(props) {
      console.log("已挂在");
      
      render(props.container?.querySelector('#app'))
    },
    // 只有子应用第一次加载会触发
    bootstrap() {
      console.log('vue app bootstrap');
    },
    // 更新
    update() {
      console.log('vue app update');
    },
    // 卸载
    unmount() {
      console.log('vue app unmount');
      app?.unmount();
    }
  });
}
